package com.xz.realdemo.builder;

import com.xz.realdemo.model.Computer;

/**
 * @author 张志航     
 * @version V1.0.0
 * @projectName design_mode
 * @title     ComputerBuilder   
 * @package    com.xz.realdemo.builder  
 * @date   2019/11/28 19:42  
 * @explain
 */
public abstract class ComputerBuilder {

    protected Computer computer = new Computer();

    abstract void buildCpu();
    abstract void buildInternal();
    abstract void buildDisk();
    abstract void buildEngine();
    abstract void buildDisplay();

    // 是否有显示屏
    public boolean havaDisplay(){
        return true;
    }

    public Computer construct(){
        this.buildCpu();
        this.buildInternal();
        this.buildDisk();
        this.buildEngine();
        // 有无显示器
        if (this.havaDisplay()){
            this.buildDisplay();
        }
        return computer;
    }

}
